package com.wn.web;

import com.wn.common.annotation.RequireRoles;
import com.wn.common.pojo.*;
import com.wn.service.TravelRouteService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;




@Api(value = "旅游路线的接口")
@RestControllerAdvice
@RequestMapping("travelRoute")
public class TravelRouteController {

    private static Logger log = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private TravelRouteService travelRouteService;

    /**
     * 根据目的地查询出该地的旅游路线
     * @param travelRoute
     * @return
     */
    @PostMapping("findTravelRouteListByName")
    public Rsp findTravelRouteListByName(@RequestBody TravelRoute travelRoute){

        Rsp rsp = travelRouteService.findTravelRouteListByName(travelRoute.getRouteEndPlace());

        return rsp;

    }

    @PostMapping("findTravelRouteByName")
    public Rsp findTravelRouteByName(@RequestBody TravelRoute travelRoute){

        System.out.println(travelRoute.toString());

        Rsp rsp = travelRouteService.findTravelRouteByName(travelRoute.getRouteEndPlace());

        return rsp;
    }

    /**
     * 查询所有的带分页的列表
     * @return
     */
    @PostMapping("queryTravelRouteList")
    @RequireRoles(roles = "super_admin",index = 0,type = ScenicSpots.class)
    public Rsp queryTravelRouteList(@RequestHeader("token") String token,@RequestBody PageParam pageParam){

        return travelRouteService.queryTravelRouteList(pageParam);

    }

    /**
     * 修改状态
     * @param travelRoute
     * @return
     */
    @PostMapping("updateNewsinfo")
    public Rsp updateNewsinfo(@RequestBody TravelRoute travelRoute){

        Rsp rsp = travelRouteService.updateNewsinfo(travelRoute);

        return rsp;

    }

    /**
     * 逻辑删除
     * @param travelRoute
     * @return
     */
    @PostMapping("deleteTravelRouteListById")
    @RequireRoles(roles = "super_admin",index = 0,type = TravelRoute.class)
    public Rsp deleteTravelRouteListById(@RequestHeader("token") String token,@RequestBody TravelRoute travelRoute){

        Rsp rsp = travelRouteService.deleteTravelRouteListById(travelRoute);

        return rsp;

    }

    /**
     *
     * @return
     */
    @PostMapping("addTravelRoute")
    @RequireRoles(roles = "super_admin",index = 0,type = TravelRoute.class)
    public Rsp addTravelRoute(@RequestHeader("token") String token,@RequestBody TravelRoute travelRoute){

        Rsp rsp = travelRouteService.addTravelRoute(travelRoute);

        return rsp;

    }

    @PostMapping("updateTravelRoute")
    @RequireRoles(roles = "super_admin",index = 0,type = TravelRoute.class)
    public Rsp updateTravelRoute(@RequestHeader("token") String token,@RequestBody TravelRoute travelRoute){

        Rsp rsp = travelRouteService.updateTravelRoute(travelRoute);

        return rsp;
    }

    /**
     * 根据id查询出路线
     * @return
     */
    @PostMapping("findTraveRouteById")
    public Rsp findTraveRouteById(@RequestBody TravelRoute travelRoute){

        Rsp rsp = travelRouteService.findTraveRouteById(travelRoute);

        return rsp;
    }

}
